﻿
$.MGJ.PackBox = [];

(function () {
    var _this = $.MGJ.PackBox;

    $.extend($.MGJ.PackBox, {
        // 显示详细数据
        Dialog_BoxShowDataObj: null,
        Dialog_BoxShowData: function (obj) {
            var id = $(obj).attr("ID");
            this.Dialog_BoxShowDataObj = $.L.dialog({
                url: ACTION_URL("BoxShowData", "FleeGoods") + "?id=" + id,
                title: "详细数据",
                width: 1100,
                height: 'auto',
                buttons: {
                    "button_cancel": {
                        type: 'primary',
                        text: '返回',
                        click: 'MODALMISS'
                    }
                },
            });
        },

        // 批量装箱
        Dialog_BatchPackingObj: null,
        Dialog_BatchPacking: function () {
            this.Dialog_BatchPackingObj = $.L.dialog({
                url: ACTION_URL("BatchPacking", "FleeGoods"),
                title: "批量装箱",
                width: 800,
                height: "auto",
                //buttons: {
                //    "button_save": {
                //        type: 'primary',
                //        text: '保存',
                //        click: function () {
                          
                //        }
                //    },
                //    "button_cancel": {
                //        type: 'default',
                //        text: '取消',
                //        click: 'MODALMISS'
                //    }
                //},
            });
        },
        // 少量装箱或补箱
        Dialog_LittlePackingObj: null,
        Dialog_LittlePacking: function () {
            this.Dialog_LittlePackingObj = $.L.dialog({
                url: ACTION_URL("LittlePacking", "FleeGoods"),
                title: "少量装箱或补箱",
                width: 800,
                height: 'auto',
                buttons: {
                    //"button_save": {
                    //    type: 'primary',
                    //    text: '关闭',
                    //    click: function () {
                    //        _this.Dialog_LittlePackingObj.close();
                    //        _this.Ajax_PackBoxPageList(1);
                    //    }
                    //},
                    //"button_cancel": {
                    //    type: 'default',
                    //    text: '取消',
                    //    click: 'MODALMISS'
                    //}
                },
            });
        },

        // 查看
        Dialog_EditPackingObj: null,
        Dialog_EditPacking: function (obj) {
            var id = $(obj).attr("ID");
            this.Dialog_EditPackingObj = $.L.dialog({
                url: ACTION_URL("EditPacking", "FleeGoods")+"?id="+id ,
                title: "查看",
                width: 800,
                height: 'auto',
                async: true,
                buttons: {
                    "button_save": {
                        type: 'primary',
                        text: '关闭',
                        click: function () {
                            _this.Dialog_EditPackingObj.close();
                            _this.Ajax_PackBoxPageList(1);
                        }
                    },
                },
            });
        },
      

    });

})(jQuery);

(function () {
    var _index = 1;
    var _this = $.MGJ.PackBox;
    $.extend($.MGJ.PackBox, {
       
        //多条件查询
        Ajax_PackBoxPageList: function (pageIndex) {
            _index = pageIndex;
            window.SearchKey = removeSpace($("#Key").val());
            $.L.ajaxHandle({
                url: ACTION_URL("PackBoxPageList", "FleeGoods") + "?pageindex=" + pageIndex,
                data: $("#SearchForm").serialize(),
                success: function (response) {
                    $("#tableList").L_bindingDataList(response);
                    //$("#tableList_left").L_bindingDataList(response);
                    //$("#tableList_right").L_bindingDataList(response);
                    for (var i = 0; i < response.PageData.length; i++) {
                        var TheText = response.PageData[i].statusText
                        if (TheText == "待编辑" || TheText == "") {
                            $(".IfTextBtn").eq(i).text("编辑")
                        } else {
                            $(".IfTextBtn").eq(i).text("查看")
                        }
                    }
                    //console.log(response)
                }
            });
        },
        //少量装箱
        Ajax_LittlePacking: function (obj) {
            var ID = $(obj).attr("ID");
            var BoxCode = $(obj).attr("BoxCode");
            var SingleCodes = $(obj).attr("SingleCodes");
            $.L.ajaxHandle({
                url: ACTION_URL("LittlePackingAdd", "FleeGoods"),
                data: {
                    ID:ID,
                    BoxCode: BoxCode,
                    SingleCodes: SingleCodes,
                },
                success: function (response) {
                   
                    // $("#tableList").L_bindingDataList(response);
                    var data = eval('(' + response + ')');
                    if (data.id > 0) {
                        $.L.msgSuccess("装箱成功！");
                        $.MGJ.PackBox.Dialog_LittlePackingObj.close();
                    }
                    else {
                        $.L.msgError(data.text);
                    }
                }
            });
        },
        //删除
        Ajax_Del: function (obj) {
            $.L.msgConfirm("确认删除该记录?", function () {
    var ID = $(obj).attr("ID");
           
            $.L.ajaxHandle({
                url: ACTION_URL("DelPacking", "FleeGoods"),
                data: {
                    id: ID,
                },
                success: function (r) {
                    // $("#tableList").L_bindingDataList(response);
                    if (r>0) {
                        $.L.msgSuccess("删除成功！");
                        _this.Ajax_PackBoxPageList(_index);
                    }
                }
            });
            })
        
        },
    });
})(jQuery);


   